﻿
Partial Class pruebas_Default2
    Inherits System.Web.UI.Page
    


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim numrows As Integer = 5
        Dim numcells As Integer = 3
        Dim j As Integer
        For j = 0 To numrows - 1
            Dim r As New TableRow()
            Dim i As Integer
            For i = 0 To numcells - 1
                Dim c As New TableCell()

                Dim lb As New Label
                lb.ID = "m" + j.ToString + i.ToString
                lb.Text = "Texto" + i.ToString
                c.Controls.Add(lb)
                c.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))

                r.Cells.Add(c)
            Next i
            tblPrincipal.Rows.Add(r)
        Next j


    End Sub

    Public Sub clikeame(ByVal sender As Object, ByVal e As EventArgs)
        Dim boton As New Button
        boton = DirectCast(sender, Button)
        Label1.Text = "Texto" & boton.Text


        For Each Row In tblPrincipal.Rows
            For Each Cell In Row.Cells
                Response.Write(Cell.ToString)
            Next
        Next

    End Sub


    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i As Integer = 1 To 4 Step 1
            Dim myBoton As New Button
            myBoton.Text = "boton " & i.ToString
            myBoton.ID = "btnInicio" & i.ToString
            AddHandler myBoton.Click, AddressOf clikeame

            Me.form1.Controls.Add(myBoton)

        Next
    End Sub
End Class
